﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Wisdom.Core;
using System.Linq;

namespace Wisdom.Web.Mvc
{
    public class DependencyResolverWrapper : IDependencyResolver
    {
        private readonly IObjectContainer container;

        public DependencyResolverWrapper(IObjectContainer container)
        {
            this.container = container;
        }

        public object GetService(Type serviceType)
        {
            if (!container.Registered(serviceType))
            {
                return null;
            }
            return container.GetService(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return this.container.GetServices(serviceType).Cast<object>();
        }
    }
}